
cc.Class({
    extends: cc.Component,

    properties: {

    },

    // LIFE-CYCLE CALLBACKS:
    ctor(){
        this._nd_cur = null;
    },

    onLoad () {
        G.gameCtrl = this;
    },

    start () {
        // 导航到 login
        G.gameCtrl.naviToLoginLayer();
    },

    naviToAllItem(data){

        // 删除所有的弹窗
        this._beforeNavi();

        // 防止bug
        this.scheduleOnce(()=>{
            let nd = cc.instantiate(G.pfRes.pf_allItem);
            nd.setParent(this.node);

            let allItem = nd.getComponent('allItem');
            allItem.initWithAllData(data);

            this._nd_cur = nd;
        });
    },

    naviToLoginLayer(){
        this._beforeNavi();
        this.scheduleOnce(()=>{
            let nd = cc.instantiate(G.pfRes.pf_login);
            nd.setParent(this.node);
            this._nd_cur = nd;
        });
    },

    _beforeNavi(){
        G.winMgr.closeAllPopLayer();
        if(this._nd_cur){
            this._nd_cur.destroy();
            this._nd_cur = null;
        }
    },

});
